import { ref,onMounted, Ref,watch,onUnmounted  } from 'vue'
import ApiTree from '~/api/ApiTree';
import CEvent from '~/utils/CEvent';
import StrUtil from '~/utils/StrUtil';
import System from '~/utils/System';

export default class VueTreeDetailMain {

    static id:string

    static that:VueTreeDetailMain

    info:Ref<any> = ref({})

    constructor(){

        VueTreeDetailMain.that = this

        onMounted(()=>{
            if(StrUtil.isNull(VueTreeDetailMain.id))
                this.back()
            this.getDeatil()
        })

        onUnmounted(()=>{
        })

    }

    /**
     * 获取详情
     */
    async getDeatil(){
        let that = VueTreeDetailMain.that
        await ApiTree.details(parseInt(VueTreeDetailMain.id)).then((data:any)=>{
            console.log("详情",data);
            data = data.data
            let infoT = that.info
            infoT.value.id = data.id
            infoT.value.name = data.name
            infoT.value.pid = data.pid
            infoT.value.type = data.type
        }).catch((e:any)=>{
        })
    }

    back(){
        System.$router.push("/tree")
    }

}